<template>
  <div>
    <div class="home">
      <div class="banner">
        <div class="banxin">
          <img src="../assets/images/home/banner.png" alt />
        </div>
      </div>
      <Title :src="Recommend" title="精品推荐" />
      <Products :arr="records" />
      <Title :src="Hot" title="热门兑换" />
      <img src="../assets/images/home/ad.png" class="ad banxin" alt />
      <Products :arr="hot" />
    </div>
    <div class="jifen">
      <Title :src="Integral" title="积分攻略" />
      <ul class="tanxin banxin">
        <li>
          <h4>签到得鸡腿</h4>
          <div class="btn">去签到</div>
        </li>
        <li>
          <h4>购课得鸡腿</h4>
          <div class="btn">去购课</div>
        </li>
        <li>
          <h4>推荐得鸡腿</h4>
          <div class="btn">去推荐</div>
        </li>
        <li>
          <h4>做任务得鸡腿</h4>
          <div class="btn">去做任务</div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { GetJingPingDataApi, HotApi } from "@/request/api";
import Title from "@/components/home/Title.vue";
import Products from "@/components/Products.vue";

export default {
  data() {
    return {
      Recommend: require("../assets/images/home/Recommend.png"),
      Hot: require("../assets/images/home/hot.png"),
      Integral: require("../assets/images/home/integral.png"),
      records: [],
      hot: []
    };
  },
  components: {
    Title,
    Products
  },
  created() {
    GetJingPingDataApi().then(res => {
      if (res.data.code === 0) {
        this.records = res.data.data.data.records;
      }
    });
    HotApi().then(res => {
      if (res.data.code === 0) {
        this.hot = res.data.data.data.records;
      }
    });
  }
};
</script>
 
<style lang = "less" scoped>
@import "../assets/base.less";
.home {
  background: #f5f5f5;
}
.banner {
  width: 100%;
  background: #fff;
  padding-bottom: 30px;
  img {
    display: block;
  }
}
.ad {
  display: block;
  margin-bottom: 30px;
}
.jifen {
  background: #fff;
  padding-bottom: 47px;
  li {
    width: 285px;
    height: 168px;
    padding-left: 21px;
    padding-top: 43px;
    box-sizing: border-box;
    transition: background-size 0.3s linear;
    background-size: 100% 100%;
    cursor: pointer;
    color: #ffffff;

    h4 {
      font-size: 24px;
      font-weight: bold;
      margin-bottom: 20px;
    }
    .btn {
      width: 96px;
      height: 27px;
      border: 1px solid #ffffff;
      text-align: center;
      line-height: 27px;
    }
    &:nth-of-type(1) {
      background-image: url(../assets/images/home/integral-01.png);
    }
    &:nth-of-type(2) {
      background-image: url(../assets/images/home/integral-02.png);
    }
    &:nth-of-type(3) {
      background-image: url(../assets/images/home/integral-03.png);
    }
    &:nth-of-type(4) {
      background-image: url(../assets/images/home/integral-04.png);
    }
    &:hover {
      background-size: 105% 105%;
    }
  }
}
</style>